#include <wiringPi.h>
#include <stdio.h>  

#define  LED_B 0   // 蓝色LED
#define  LED_G 2   // 绿色LED
#define  LED_R 3   // 红色LED

#define  btn_pin 1 // 按钮引脚

int flag = 0;

void blank(void){
    flag = 1;
}


int main (void)
{
    wiringPiSetup();
    pinMode(LED_R, OUTPUT);
    pinMode(btn_pin, INPUT);
    pullUpDnControl (btn_pin, PUD_UP);
    delay(100);
    wiringPiISR(btn_pin,INT_EDGE_FALLING,&blank);
    while(1){
        if(flag == 1){
            delay(20); // 延时 按钮销抖
            if(flag == 1){
                flag = 0;
                digitalWrite(LED_R,HIGH);
                delay(100);
                digitalWrite(LED_R,LOW);
            }
        }
    }
	return 0;
}